
function adapterServiceItemData(data) {
  const list = []
  data.inputData.forEach(item => {
    const row = item.memberList ? item.memberList[0] : {}
    list.push({
      paramName: item.name,
      paramKey: item.identifier,
      category: item.category,
      options: row.specs,
      min: item.spec.min ? item.spec.min - 0 : -Infinity,
      max: item.spec.max ? item.spec.max - 0 : Infinity,
      showParamOpen: false,
      openParam: {
        isOpen: false,
        dataType: item.category,
        description: '',
        enumValue: [],
        maxValue: undefined,
        value: undefined
      },
      value: undefined
    })
  })
  return list
}

function generatorTreeSelectData(treeData, findItem) {
  const res = []
  treeData.forEach(item => {
    const selectedNode = item.children.find(child => child.value === findItem)
    if (selectedNode) {
      res.push(item.value, selectedNode.value)
    }
  })
  return res
}

export {
  adapterServiceItemData,
  generatorTreeSelectData
}
